﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Kernel
{
    public partial class FormBase : Form, IControlEx
    {
        public FormBase()
        {
            InitializeComponent();

            ControlExList = new List<IControlEx>();
        }

        public FormBase(IControlPad pad)
            :this()
        {
            this._pad = pad;
        }

        public List<IControlEx> ControlExList { get; set; }

        #region 实现IControlEx接口
        void IControlEx.Init() { }
        void IControlEx.Load() { }
        void IControlEx.Update() { }
        void IControlEx.Save() { }
        bool IControlEx.Updated { get; }
        #endregion

        /*私有变量*/
        protected IControlPad _pad = null;


        public void AddExControl(IControlEx item)
        {
            this.ControlExList.Add(item);
        }
        /// <summary>
        /// 初始化全部实现IControlEx接口的控件
        /// </summary>
        public void InitAllExControls()
        {
            foreach (IControlEx ui in ControlExList)
                ui.Init();
        }

        /// <summary>
        /// 加载全部实现IControlEx接口的控件(这里放那些只需要加载一次的控件)
        /// </summary>
        public void LoadAllExControls()
        {
            foreach (IControlEx ui in ControlExList)
                ui.Load();
        }

        /// <summary>
        /// 更新全部实现IControlEx接口的控件(这里放那些需要多次刷新的控件)
        /// </summary>
        public void UpdateAllExControls()
        {
            foreach (IControlEx ui in ControlExList)
                ui.Update();
        }

        /// <summary>
        /// 保存全部实现IControlEx接口的控件(这里放那些需要多次刷新的控件)
        /// </summary>
        public void SaveAllExControls()
        {
            foreach (IControlEx ui in ControlExList)
                ui.Save();
        }
    }
}
